package com.zhangmeng.online.exam.entity;

import com.zhangmeng.online.exam.entity.baseEntity.BaseEntity;
import lombok.*;

import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import java.util.ArrayList;
import java.util.List;

/**
 * 考试信息
 * @author zm
 * @date 2025/4/17 16:26
 * @version: 1.0
 */
@NoArgsConstructor
@ToString(exclude = {"user","paper","examAnswers"})
@Getter
@Setter
@AllArgsConstructor
@Entity
@Table(name = "exam")
public class Exam extends BaseEntity<Long> {

    public enum Status{

        NOT_STARTED(0,"未开始"),
        IN_PROGRESS(1,"进行中"),
        COMPLETED(2,"已结束");


        private int index;

        private String desc;

        Status(int index, String desc) {
            this.index = index;
            this.desc = desc;
        }

        public int getIndex() {
            return index;
        }

        public void setIndex(int index) {
            this.index = index;
        }

        public String getDesc() {
            return desc;
        }

        public void setDesc(String desc) {
            this.desc = desc;
        }
    }

    @ManyToOne
    private User user;//考试人

    @ManyToOne
    private Paper paper;//试卷

    private Status status;//考试状态 0 未开始 1 进行中 2 已结束

    @OneToMany(mappedBy = "exam")
    private List<ExamAnswer> examAnswers = new ArrayList<>();//考试信息
}
